package work;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import util.ConncetionUtil;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

public class Sender {
    public static final String QUEUENAME="zfz";

    public static void main(String[] args) {
        Connection connection = ConncetionUtil.getConnection();
        try {
            Channel channel = connection.createChannel();
            channel.queueDeclare(QUEUENAME,false,false,false,null);
            for (int i = 0; i < 99; i++) {
                channel.basicPublish("",QUEUENAME,null,("小祖宗对大龙说的话:"+i).getBytes(StandardCharsets.UTF_8));

            }
            //如果生产者作用已经完结,关闭它
            channel.close();
            connection.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
